package com.xjy.system.domain;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.AssertFalse;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;

import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Data;

@Data
@Entity
@SQLDelete(sql = "update sys_deposit_back set del=1 where id=? and version=?")
@Table(indexes = {@Index(columnList = "depId")})
@Where(clause = "del=0")
public class SysDepositBack {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	/**
	 * 所清退的押金ID
	 */
	@Column(nullable = false,updatable = false)
    @NotNull
	private Long depId;

	/**
	 * 删除
	 */
	@AssertFalse
	@Column(nullable = false,updatable = false)
    private Boolean del;

    /** 清退时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Past(message = "必须为过去的时间")
    @NotNull
    private Date depTime;
    
    @Column(updatable = false)
    private Date createTime;
    
    /** 押金收据影像 */
    @Column(length = 255)
    @Size(max = 255)
    private String depColImg;
    
    /** 经办人id */
    @NotNull
    private Long depHandlerId; 
    
    /** 往来id，对方 */
    @NotNull
    private Long depPaiorId;
    
    /** 押金收款/支付账户ID */
    @NotNull
    private Long depPayaccountId;
    
    /** 清退金额*/
    @DecimalMin(value = "0.01")
    private BigDecimal money;
    /** 清退前共清退金额*/
    private BigDecimal preMoney;
    /** 清退后共清退金额*/
    private BigDecimal lastMoney;

    /** 备注 */
    @Column(length = 500)
    @Size(max = 250)
    private String remark;
    
    @Version
    private Integer version;
	
}
